﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using PropertyManagment.entity.dto;
using PropertyManagment.service;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

namespace PropertyManagment.controllers {
    public class BaseController<T> : Controller {

		public ILogger<BaseController<T>> logger { get; set; }
		public SysUserService sysUserService { get; set; }
		public SysRoleService sysRoleService { get; set; }
		public SysMenuService sysMenuService { get; set; }
		public SysUserRoleService sysUserRoleService { get; set; }
		public SysRoleMenuService sysRoleMenuService { get; set; }

		//public BaseController(ILogger<BaseController> logger, SysUserService sysUserService, SysRoleService sysRoleService, SysMenuService sysMenuService) {
		//	this.logger = logger;
		//	this.sysUserService = sysUserService;
		//	this.sysRoleService = sysRoleService;
		//	this.sysMenuService = sysMenuService;
		//}

		protected Page<T> getPage() {
			//get使用HttpContext.Request.Query
			//post使用HttpContext.Request.Form
			string current = HttpContext.Request.Query["current"];
			current = current.IsNullOrEmpty() ? "1" : current;
			string size = HttpContext.Request.Query["size"];
			size = size.IsNullOrEmpty() ? "10" : size;

			return new Page<T>(int.Parse(current), int.Parse(size));
        }
    }
}
